package com.itheima.edu.info.manager.dao;

import com.itheima.edu.info.manager.domain.Student;
import com.itheima.edu.info.manager.domain.Teacher;

public class TeacherDao {
    private static Teacher[] te = new Teacher[5];

    //添加
    public boolean addTeacher(Teacher ter) {
        int index = -1;
        for (int i = 0; i < te.length; i++) {
            Teacher t = te[i];
            if (t == null) {
                index = i;
                break;
            }
        }
        if (index == -1) {
            return false;
        } else {
            te[index] = ter;
            return true;
        }
    }

    public Teacher[] getTe() {
        return te;
    }

    //删除id对应对象
    public void deleteTeacher(String id) {
        for (int i = 0; i < te.length; i++) {
            Teacher t = te[i];
            if (t != null && t.getId().equals(id)) {
                te[i] = null;
            }
        }
    }

    //修改对象
    public void changeTeacher(Teacher ter) {
        for (int i = 0; i < te.length; i++) {
            Teacher t = te[i];
            if (t != null && t.getId().equals(ter.getId())) {
                te[i] = ter;
            }
        }
    }
}
